package mpicbg.imagefeatures;

import java.util.ArrayList;

public class average
{
	public static ArrayList<Float> avg(ArrayList<Float> featfloats)
	{
		int length = featfloats.size()/130;
		System.out.println("length "+length);
		ArrayList<Float> featurefloats = new ArrayList<Float>();
		Float[][] array = new Float[length][130];
		Float[] avgfloats=new Float[130];
		Float f = new Float(0);
		for(int i=0;i<130;i++)
			avgfloats[i]=f;
		int k=0;
		for(int i=0;i<length;i++)
		{
			for(int j=0;j<130;j++)
			{
				array[i][j]=featfloats.get(k++);
				/*if(length==0)
				{
					array[j]=array[j]+featfloats.get(j);
					featurefloats.set(j, array[j]);
				}
				else
				{
				array[j]=array[j]+featfloats.get(i*j);

				}*/
			}

		}
		for(int i=0;i<130;i++)
		{
			for(int j=0;j<length;j++)
			{
				avgfloats[i]+=array[j][i];
				//System.out.println("the avg"+avgfloats[i]);
			}
		}
		if(length==0)
		{
			for(int m=0;m<130;m++)
				featurefloats.add(f);
		}
		else
		{
		for(int m=0;m<130;m++)
			featurefloats.add(avgfloats[m]/length);
		}
		return featurefloats;
	}
}